package com.otitan.forest.right.exceptionhandle;

import com.otitan.forest.right.exception.LoginException;
import com.otitan.webapp.framework.basepro.model.DataResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Description: 当前类作用描述
 * @Author: xiazw
 * @CreateDate: 2020/8/4 15:40
 */
@RestControllerAdvice
@Slf4j
public class LoginExceptionHandle {
    @ExceptionHandler(value = LoginException.class)
    public DataResult loginExceptionException(LoginException e) {
        log.error("Exception,exception:{}", e, e);
        return DataResult.fail(e.getMessage());

    }

    @ExceptionHandler(value = UnauthorizedException.class)
    public DataResult unauthorizedExceptionException(UnauthorizedException e) {
        log.error("Exception,exception:{}", e, e);
        return DataResult.fail("暂无权限，请联系管理员");

    }
}